<!DOCTYPE html>
<html lang="zh-cn"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head th:replace="common::head"></head>
<body>
<div th:replace="common::top"></div>
<br/>
<h1>编辑客户</h1>
<br/>
<form th:action="@{edit}" method="post" id="editForm">
    <label>客户:</label>
    <input type="text" name="name" th:value="${custom.name}" required>
    <!--
    <br/>
    <label>电话:</label>
    <input type="text" name="phone" th:value="${custom.phone}">
    -->
    <br/>
    <label>备注:</label>
    <input type="text" name="remark" th:value="${custom.remark}">
    <br/>
    <input type="number" name="id" th:value="${custom.id}" hidden>
    <br/>
    <input type="submit" value="提交" style="width:220px;">
</form>
<p>
    <a href="javascript:history.back(-1);">上一页</a>
    <a href="../index.html" th:href="@{/index.html}">主页</a>
</p>

<script>
    $("#editForm").submit(function(e){
        e.preventDefault();

        $.ajax({
            type: $("#editForm").attr("method"),
            url: $("#editForm").attr("action"),
            data: $("#editForm").serialize(),
            success: function(response){
                alert("提交成功");
                window.location.href="list.html";
            },
            error: function(response){
                alert("提交失败");
            }
        });
    });
</script>

</body>
</html>